// FILE: Chip8Debugger.h by Richard Hughes 11/05/2012
//
// DESC: Defines the the Chip 8 debugger

#ifndef __chip8debugger_h__
#define __chip8debugger_h__

// INCLUDES
#include "IDebugger.h"

// NAMESPACES
namespace Emulator
{
namespace Chip8
{

/*************************************************************/
//
// CLASS: Chip8Debugger
//
// DESC: Defines the chip 8 debugger interface
//
/*************************************************************/

class Chip8Debugger
{
private:

	bool _isAttached;
	address _currentAddress;

	// at the moment, only support one breakpoint
	address _breakPoint;

	bool _isStepping;

public:

	Chip8Debugger()
		: _isAttached(false),
		  _currentAddress(0),
		  _breakPoint(0),
		  _isStepping(false)
	{
	}
	~Chip8Debugger()
	{
	}

	bool IsAttached()
	{
		return this->_isAttached;
	}

	void Break()
	{
		this->_isAttached = true;
		this->AddBreakpoint(this->_currentAddress);
	}

	void Continue()
	{
		this->_isAttached = false;
		this->_isStepping = false;
	}

	void AddBreakpoint(address add)
	{
		this->_breakPoint = add;
	}

	const address* GetBreakpoints()
	{
		return &this->_breakPoint;
	}

	void Step(Chip8CPU* cpu, Chip8RAM* ram, int ops = 1)
	{
		this->_isStepping = true;

		for(int i = 0; i < ops; i++)
			cpu->Tick(ram);
	}

	void SetStep(address add)
	{
		this->_currentAddress = add;
	}

	bool IsStepping()
	{
		return this->_isStepping;
	}

}; // Chip8Debugger

} // Chip8
} // Emulator

#endif // __chip8debugger_h__

// EOF: IDebugger.h